<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 不希望一个变量造成全局污染，有常驻内存，就使用闭包 */
        function create(){
            let a=100;
            return function(){
                console.log(a);
            }
        }
        /*  */
        var fn =crteate();
        fn();
        /* fn是全局变量，它没有调用a的内存就不会释放 */
    </script>
</body>
</html>